package com.community.admin.modules.contents;

import com.community.common.core.utils.Result;
import com.community.feign.contents.dto.SlideshowDTO;
import com.community.feign.contents.slideshow.Slideshowfeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @className: Slideshow
 * @author: shuishui
 * @date: 2023/03/01 15:15
 */
@RestController
@RequestMapping("/slideshow")
public class SlideshowController {

    @Autowired
    private Slideshowfeign slideshowfeign;

    @GetMapping("/selectAll")
    public Result selectAll(){
        List<SlideshowDTO> slideshowDTOS = slideshowfeign.selectAll();
        return new Result().ViewOk(slideshowDTOS);
    }
    @GetMapping("/removeById/{id}")
    public boolean removeById(@PathVariable Integer id){
        return slideshowfeign.removeById(id);
    }
    @PostMapping("/save")
    public boolean sace(@RequestBody SlideshowDTO SlideshowDTO){
        Date date = new Date();
//        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
        SlideshowDTO.setCreatTime(date);

        return slideshowfeign.save(SlideshowDTO);
    }
}
